<template>
  <div>
    home组件
    <el-button type="primary">主要按钮</el-button>
     <el-rate v-model="rate"></el-rate>
    <hr>
    modulea中的num
    <!-- {{ $store.state.modulea.num }} -->
    <button @click="addNum">增加模块a中的num</button>
    {{ num1 }}
    <hr>
    moduleb中的num
    <!-- {{ $store.state.moduleb.num }} -->
    {{ num2 }}
  </div>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
export default {
  data () {
    return {
      rate: 4
    }
  },
  computed: {
    ...mapState({
      num1: state => state.modulea.num,
      num2: state => state.moduleb.num
    })
  },
  methods: {
    // ...mapMutations(['modulea/add_num']),
    ...mapMutations('modulea', ['add_num']),
    addNum () {
      this.add_num(30)
      // this['modulea/add_num'](20)
    }
    /* addNum () {
      this.$store.commit('modulea/add_num', 10)
    } */
  },
  mounted () {
    console.log(this.$store)
  }
}
</script>

<style lang="scss" scoped>

</style>
